package com.wander.patterns.structure.proxy.dynamicProxy;

import java.lang.reflect.Proxy;

/**
 * @description: 动态代理实例
 * @author: zhuyong
 * @create: 2019-09-04 10:04
 **/
public class Client {
    public static void main(String[] args) {
        RealStar realStar = new RealStar();
        //JDK自带的代理方式实现:
        StarHandler starHandler = new StarHandler(realStar);
        //动态生成代理类的代码,后续Star接口的所有方法都会调用 starHandler.invoke()
        Star proxy = (Star) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(),
                new Class[]{Star.class},starHandler);

        proxy.sing();
    }


}
